# Задание E
n = int(input())
height_map = [list(input().split()) for i in range(n)]
List = []

for i in range(len(height_map) - 1):
    for j in range(len(height_map[i]) - 1):
        try:
            if height_map[i][j] > height_map[i][j-1] and height_map[i][j] > height_map[i-1][j] and height_map[i][j] > height_map[i+1][j] and height_map[i][j] > height_map[i][j+1]:
                List.append(height_map[i][j])
        except IndexError:
            continue
print(len(List))
print(List)